<?php
class AdminMessengerUser extends CActiveRecord{
    
    public static function model($className = __CLASS__) {
        return parent::model ( $className );
    }
    
    // dat luat cho model
    public function rules(){}         

    // goi den bang can ket noi   
    public function tableName() {                  
        return 'messenger_user';
    }

    // nhan cac thuong tinh 
    public function attributeLabels(){}
    
    public function insertRow($mes_id,$user_id){
        $connect = Yii::app()->db;
        $sql =   "INSERT INTO messenger_user (mes_id, user_id) VALUES (:mes_id, :user_id)";
        $command = $connect->createCommand ($sql);
        $command->bindValue ( ":mes_id", $mes_id, PDO::PARAM_STR );  
        $command->bindValue ( ":user_id", $user_id, PDO::PARAM_STR );          
        $result = $command->execute();
        return $result;        
    }
    
    public function deleteRow($arr_id){
        $sql = "DELETE FROM messenger_user WHERE mes_id IN (".$arr_id.")";
        $connect = Yii::app()->db;
        $command = $connect->createCommand ($sql); 
        $result = $command->execute();
        return $result;          
    }
}